package dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class PwdReset {
    private static Connection conn=DataBaseConnect.getConn();
    private static String sql="update account set Password=? where id=?";
    private static PreparedStatement pstmt;
    static {
        try {
            pstmt=conn.prepareStatement(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
    public static boolean Reset(String id,String pwd){
        try {
            pstmt.setString(1,pwd);
            pstmt.setString(2,id);
            int count=pstmt.executeUpdate();
            if(count==1){
                System.out.println("修改成功");
                return true;
            }
        } catch (SQLException e) {
            System.out.println("修改密码失败");
            return false;
        }
        return false;
    }
}
